package thread;

//创建一个类继承Thread
class MyThread extends Thread{
    @Override
    public void run() {     //是线程的入口方法
        while(true){
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}

//创建一个线程； //主线程的入口方法
public class Test1 {
    public static void main(String[] args) throws InterruptedException {
         Thread thread = new MyThread();
         thread.start();
      while(true){
          System.out.println("hello main");
          Thread.sleep(1000);
      }
    }
}
 